import {
    PrimaryGeneratedColumn,
    CreateDateColumn,
    UpdateDateColumn,
    BaseEntity as TypeORMBaseEntity,
    Column,
} from 'typeorm';
import { DelFlag } from './enums/del-flag.enum';

export abstract class BaseEntity extends TypeORMBaseEntity {
    /** 主键 */
    @PrimaryGeneratedColumn('uuid')
    id: string;

    /** 创建时间 */
    @CreateDateColumn({ type: 'timestamp', name: 'created_time', comment: '创建时间' })
    createdAt: Date;

    /** 更新时间 */
    @UpdateDateColumn({ type: 'timestamp', name: 'updated_time', comment: '更新时间' })
    updatedAt: Date;

    /**
     * 删除标记
     */
    @Column({ type: 'enum', enum: DelFlag, default: DelFlag.ACTIVE })
    del_flag: DelFlag;
}
